#include <iostream>
#include "Matrix.h"
using namespace std;

Matrix::Matrix(int sz):
  size(sz)
{
  int i;

  mat = new double * [size];
  for (i = 0; i < size; i++)
    mat[i] = new double [size];

  for(int i = 0; i < size; i++)
  {
	  for(int j = 0; j < size; j++)
		  mat[i][j] = 0;
  }
}


Matrix::~Matrix()
{
  int i;
  for (i = 0; i < size; i++)
    delete [] mat[i];

  delete [] mat;
}


double * Matrix::operator[] (int row_index)  
{
	//cout <<	"Row index" << row_index << ": " << mat[row_index] << endl;
   
	return mat[row_index];
}


double* Matrix::operator*(const double right[])
{
	double* arr = new double [size];

	for(int i = 0; i < size; i++)
		arr[i] = 0;

	//cout << endl << "MATRX TEST:" << endl;
	for(int i = 0; i < size; i++)
	{
		for(int j = 0; j < size; j++)
		{
			arr[i] = arr[i] + mat[i][j]*right[j];
			if(i == 0 && mat[i][j] != 0)
			{
				//cout << right[j] << "		" << mat[i][j] << endl;
			}
		}
	}
	//cout << mat[0][100] << "		" << right[0] << endl;
	return arr;
}
